import Vue from 'vue'
import Router from 'vue-router'
import RoomManagement from './views/RoomManagement.vue'
import GuestManagement from './views/GuestManagement.vue'
import BookingManagement from './views/BookingManagement.vue'
import StaffManagement from './views/StaffManagement.vue'
import ServiceManagement from './views/ServiceManagement.vue'
import FinanceReport from './views/FinanceReport.vue'
import RoomStatus from './views/RoomStatus.vue'
import Login from './views/Login.vue'

Vue.use(Router)

const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => {
    if (err.name!== 'NavigationDuplicated') throw err
  })
}

const originalReplace = Router.prototype.replace
Router.prototype.replace = function replace(location) {
  return originalReplace.call(this, location).catch(err => {
    if (err.name!== 'NavigationDuplicated') throw err
  })
}

export default new Router({
  routes: [
    {
      path: '/',
      redirect: '/rooms'
    },
    {
      path: '/rooms',
      name: 'rooms',
      component: RoomManagement
    },
    {
      path: '/guests',
      name: 'guests',
      component: GuestManagement
    },
    {
      path: '/bookings',
      name: 'bookings',
      component: BookingManagement
    },
    {
      path: '/staff',
      name: 'staff',
      component: StaffManagement
    },
    {
      path: '/services',
      name: 'services',
      component: ServiceManagement
    },
    {
      path: '/finance',
      name: 'finance',
      component: FinanceReport
    },
    {
      path: '/room-status',
      name: 'room-status',
      component: RoomStatus
    },
    {
      path: '/login',
      name: 'login',
      component: Login
    }
  ]
})